#ifndef WINDOWGLWIDGET_H
#define WINDOWGLWIDGET_H

#include <QGLWidget>
#include <QMouseEvent>
#include <QKeyEvent>
#include <QTimer>
#include <QVector>

#include "parafluidbox.h"
#include "parafluidcamera.h"
#include "parafluidcolor.h"
#include "parafluidmultihashmap.h"
#include "parafluidsimulation.h"

using namespace ParaFluid;

class WindowGLWidget : public QGLWidget {
   Q_OBJECT
   
public :
   enum ObjectType{Box, Pyramid, QTLogo};
   
   WindowGLWidget(QWidget * parent = 0);
   ~WindowGLWidget();
   
protected :
   void initializeGL();
   void resizeGL(int width , int height);
   void paintGL();
   void mouseDoubleClickEvent(QMouseEvent *event);
   void mousePressEvent(QMouseEvent *event);
   void mouseMoveEvent(QMouseEvent *event);
   void wheelEvent(QWheelEvent * event);
   void keyPressEvent(QKeyEvent * event);

private :
   void updateCameraGL();
   
   double normalizeAngle(const double & angle);
   
   void initRandomObjectPositions(int objectQuantity);
   void drawCube(const double & side, const Vector & position, const Color & color);
   void drawWireCube(const ParaFluid::Box & box, const Color & color);
   static void drawSphere(const double & radius, const int slicesAroundZaxis, const int stacksAlongZaxis, const Vector & position, const Color & color); 
   void output(/*int x, int y, */char * string);
   void drawRandomCubes(int cubeQuantity);
   void drawRandomSpheres(int shereQuantity);

   double _scaleFactor;
   double _cRadius;
   QPoint _lastPos;
   QColor _Green;
   QColor _LightGray;
   QColor _Black;
   Camera _camera;
   double _atomRadius;
   
   //positions of the cubes
   double positionz[10];
   double positionx[10];
   QVector<Vector> _RandObjPositions;
   
   QTimer _FpsTimer;
   int _StepCounter;
   int _LastStepCounter;
   bool _UpdateFPS;
   bool _ShowFPS;
   
   
public slots:
   void setCameraOrientationX(const double & angle);
   void setCameraOrientationY(const double & angle);
   void setCameraOrientationZ(const double & angle);
   void uniformScale(const double & scaleFactor);
   
signals:
   void xRotationChanged(const double & angle);
   void yRotationChanged(const double & angle);
   void zRotationChanged(const double & angle);
   
private slots:	

	void updateFPS();

private:
	
	/**
	* Simulation
	*/
	Simulation _simulation;

};

#endif
